package cn.seaboot.commons.http;

import java.io.Serializable;

/**
 * 常用的参数配置
 * <p>
 * 并不规定此配置类非要配置在yml中，通常来说，一个配置就已经能够满足使用，
 * 如果有必要，仍然可以用new的方式，去构建多个配置实例
 *
 * @author Mr.css
 * @version 2019/12/7 17:10
 */
public class HttpProperties implements Serializable {
    private static final long serialVersionUID = 840969243768390816L;
    /**
     * 是否启用
     */
    private boolean enable;
    /**
     * 开启清理线程
     */
    private boolean openCleanThread;
    /**
     * 最大连接数
     */
    private int maxTotal = 5;
    /**
     * 每一次获取的连接数量
     */
    private int maxPerRoute = 2;
    /**
     * 连接超时
     */
    private int connectTimeout = 5000;
    /**
     * 读取数据超时
     */
    private int socketTimeout = 7000;
    /**
     * 请求超时
     */
    private int connectionRequestTimeout = 20000;

    public boolean isEnable() {
        return enable;
    }

    public void setEnable(boolean enable) {
        this.enable = enable;
    }

    public int getMaxTotal() {
        return maxTotal;
    }

    public void setMaxTotal(int maxTotal) {
        this.maxTotal = maxTotal;
    }

    public int getMaxPerRoute() {
        return maxPerRoute;
    }

    public void setMaxPerRoute(int maxPerRoute) {
        this.maxPerRoute = maxPerRoute;
    }

    public int getConnectTimeout() {
        return connectTimeout;
    }

    public void setConnectTimeout(int connectTimeout) {
        this.connectTimeout = connectTimeout;
    }

    public int getSocketTimeout() {
        return socketTimeout;
    }

    public void setSocketTimeout(int socketTimeout) {
        this.socketTimeout = socketTimeout;
    }

    public int getConnectionRequestTimeout() {
        return connectionRequestTimeout;
    }

    public void setConnectionRequestTimeout(int connectionRequestTimeout) {
        this.connectionRequestTimeout = connectionRequestTimeout;
    }

    public boolean isOpenCleanThread() {
        return openCleanThread;
    }

    public void setOpenCleanThread(boolean openCleanThread) {
        this.openCleanThread = openCleanThread;
    }

    @Override
    public String toString() {
        return "HttpClientProperties{" +
                "enable=" + enable +
                ", openCleanThread=" + openCleanThread +
                ", maxTotal=" + maxTotal +
                ", maxPerRoute=" + maxPerRoute +
                ", connectTimeout=" + connectTimeout +
                ", socketTimeout=" + socketTimeout +
                ", connectionRequestTimeout=" + connectionRequestTimeout +
                '}';
    }
}
